
# 流年
'''
B = b**(0.5) * 12
'''


# coding:utf-8
import cv2
import numpy as np
import time
import math
import Utility.LUT as LUT


start = time.perf_counter()
#   怀旧
print('计算流年颜色表......')
# r
table = np.empty(256)
print('计算B通道中...')
for r in range(0, 255):
    v = round(math.sqrt(r) * 12)
    if v > 255:
        v = 255
    table[r] = v

table = np.uint8(table)
np.save('years-b', table)

end = time.perf_counter()
print('流量颜色表计算完成,耗时', end-start)




# np.save('r2' ,table)
img = cv2.imread('h1.jpg')
# img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
dist = img.copy()
# dist[:,:,0] = cv2.LUT(dist, table)

# table = np.load('r.npy')

dist[..., 2] = cv2.LUT(dist[..., 2], table)
end = time.perf_counter()
print('找查耗时', end-start)
# cv2.LUT()
# 显示图像
cv2.imshow('src', img)
cv2.imshow('dst', dist)
cv2.waitKey()
cv2.destroyAllWindows()
